<template>
  <view class="news-system-item" @click="gotoPage(props.item)">
    <view style="flex:1">
      <view class="title u-line-2">{{ props.item.title }}</view>
      <view class="tips">{{ props.item.text }}</view>
      <view class="time">{{ props.item.createdAt }}</view>
    </view>
    <img class="img" v-if="props.item.image" :src="$countImgUrl(props.item.image) + '?x-oss-process=image/resize,m_fill,limit_0,h_80,w_80'">
  </view>
</template>

<script setup>
import { getCurrentInstance } from 'vue'
const { $countImgUrl } = getCurrentInstance().appContext.config.globalProperties
const props = defineProps({
  item: {
    type: Object,
    default: () => {}
  }
})
const gotoPage = (item) => {
  // 跳转 ：99、H5跳转；0、无  1、首页；2、个人中心；3、作品详情；4、审核动态列表；5、点赞、收藏；6、评论；7关注；8、系统；9、评论点赞；10、首页接收新动态；11、余额详情页；12、提现历史；13、求血广场；14、求血详情页, 15、订单详情页面，16、跳转link
  switch (item.jump) {
    case 99:
      jumpH5(item.link)
      break
    case 1:
      uni.switchTab({
        url: '/pages/evnetsList'
      })
      break
    case 2:
      uni.switchTab({
        url: '/pages/personal'
      })
      break
    case 3:
      jumpDetail(item.link)
      break
    case 15: // 订单详情页面
      uni.navigateTo({
        url: item.link
      })
      break
    case 16:
      uni.navigateTo({
        url: item.link
      })
      break
    default:
      break
  }
}
// 跳转H5
const jumpH5 = (url) => {
  if (url.indexOf('http') === -1) {
    uni.navigateTo({
      url,
      fail: () => {
        uni.switchTab({
          url
        })
      }
    })
  } else {
    uni.navigateTo({
      url: '/activity/webUrl?url=' + encodeURIComponent(url)
    })
  }
}
// 作品详情
const jumpDetail = (data) => {
  console.log(JSON.parse(data))
  data = JSON.parse(data)
  if (data.type === 'video') {
    uni.navigateTo({
      url: `/details/detailVideo?id=${data.id}&type=alone`
    })
  } else {
    uni.navigateTo({
      url: `/details/detailImg?id=${data.id}`
    })
  }
}
// 求血详情
const jumpBloodDetail = (data) => {
  data = JSON.parse(data)
  uni.navigateTo({
    url: `/blood/resortDetail?id=${data.id}`
  })
}
</script>

<style scoped lang="scss">
.news-system-item{
  display: flex;
  background: #FFFFFF;
  border-radius: 20px;
  padding: 30rpx;
  border-radius: 20rpx;
  margin-bottom: 10rpx;
  font-size: 24rpx;
  line-height: 24rpx;
  color: #414141;
  .img{
    width: 80rpx;
    height: 80rpx;
    border-radius: 8rpx;
    margin-left: 96rpx;
  }
  .title{
    font-size: 28rpx;
    line-height: 36rpx;
    font-weight: bold;
    margin-bottom: 20rpx;
  }
  .tips{
    margin-bottom: 10rpx;
    line-height: 32rpx;
  }
  .time{
    color: #999;
  }
}
</style>
